public class Calculator {

    // 加法
    public double add(double num1, double num2) {
        return num1 + num2;
    }

    // 减法
    public double subtract(double num1, double num2) {
        return num1 - num2;
    }

    // 乘法
    public double multiply(double num1, double num2) {
        return num1 * num2;
    }

    // 除法
    public double divide(double num1, double num2) {
        if (num2 == 0) {
            throw new IllegalArgumentException("除数不能为0");
        }
        return num1 / num2;
    }

    // 求平方
    public double square(double num) {
        return num * num;
    }
}